CLS
OPEN "bclock.in" FOR INPUT AS #1
OPEN "bclock.out" FOR OUTPUT AS #2

INPUT #1, n
FOR i = 1 TO n
  INPUT #1, in$

  FOR j = 1 TO LEN(in$)
    IF MID$(in$, j, 1) = ":" THEN
      h = VAL(MID$(in$, 1, j - 1))
      m = VAL(MID$(in$, j + 1, LEN(in$) - j))
    END IF
  NEXT j

  IF m > 0 THEN
    ans = 0
  ELSE
    IF h > 12 THEN
      ans = h - 12
    ELSE
      ans = h + 12
    END IF
  END IF

  PRINT #2, LTRIM$(STR$(ans))
NEXT i

CLOSE #1, #2
END

